//
//  NewsHeaderView.m
//  yunyan
//
//  Created by haichuang on 2018/2/12.
//  Copyright © 2018年 haichuang. All rights reserved.
//

#import "NewsHeaderView.h"

@implementation NewsHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(instancetype)init{
    self = [super init];
    if (self != nil){
        self.backgroundColor = [UIColor whiteColor];
        
        [self createHeaderView];
        
    }
    return self;
    
}
-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self != nil) {
        self.backgroundColor = [UIColor whiteColor];
        [self createHeaderView];
    }
    
    return self;
    
}




-(void)createHeaderView{
    WeakSelf;
    _lineView1 = [[UIView alloc] init];
    [self addSubview:_lineView1];
    [_lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo (weakSelf);
        make.height.equalTo (@(1.0f));
    }];
    _lineView1.backgroundColor = RGBA(240, 240, 240, 1);
    _leftLable = [[UILabel alloc]init];
    [self addSubview:_leftLable];
    [_leftLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo (weakSelf.mas_left).offset (14.f);
        make.centerY.equalTo (weakSelf.mas_centerY);
        
    }];
    _leftLable.font = [UIFont fontWithName:@"PingFang-SC-Bold" size:18];
    _leftLable.textColor = RGBA(51, 51, 51, 1);
    _leftLable.text = @"热门新闻";
    
    _commentBtn = [[UIButton alloc] init];
    [self addSubview:_commentBtn];
    [_commentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo (weakSelf.mas_right).offset (-10.f);

        make.bottom.top.equalTo (_leftLable);

    }];

    [_commentBtn setTitle:@"最多评论" forState:UIControlStateNormal];
   // [_commentBtn setTitleColor:RGBA(153, 153, 153, 1)];
    _commentBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [_commentBtn addTarget:self action:@selector(commentBtnClicked) forControlEvents:UIControlEventTouchUpInside];

    [_commentBtn setTintColor:RGBA(153, 153, 153, 1)];
      [_commentBtn setTitleColor:RGBA(153, 153, 153, 1) forState:UIControlStateNormal];
    
   
    UIView * lineView = [[UIView alloc] init];
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo (_commentBtn.mas_left).offset (-5.f);
        make.width.equalTo (@(1));
        make.top.equalTo (_commentBtn.mas_top).offset (8.f);
         make.bottom.equalTo (_commentBtn.mas_bottom).offset (-8.f);
    }];
    lineView.backgroundColor = RGBA(51, 51, 51, 1);
 
    
    _hotBtn = [[UIButton alloc] init];
    [self addSubview:_hotBtn];
    [_hotBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo (lineView.mas_left).offset (-5.f);
        make.top.bottom.equalTo (_commentBtn);
    }];
    [_hotBtn setTitle:@"热门" forState:UIControlStateNormal];
   
    _hotBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [_hotBtn addTarget:self action:@selector(hotBtnClicked) forControlEvents:UIControlEventTouchUpInside];

    [_hotBtn setTitleColor:RGBA(153, 153, 153, 1) forState:UIControlStateNormal];
    
    _lineView2 = [[UIView alloc] init];
    [self addSubview:_lineView2];
    [_lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo (weakSelf);
        make.height.equalTo (@(1.0f));
    }];
    _lineView2.backgroundColor = RGBA(240, 240, 240, 1);
    
}

-(void)commentBtnClicked{
    
    if (_commentBtnBlock) {
        _commentBtnBlock();
    }
    
    
}



-(void)hotBtnClicked{
    if (_hotBtnBlock) {
        _hotBtnBlock();
        
    }
    
    
}
@end
